package com.kust.smarthome.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kust.smarthome.web.dto.CommodityDto;
import com.kust.smarthome.web.model.Commodity;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommodityMapper extends BaseMapper<Commodity> {

    /*name intro money viewCount imgurl1*/

    @Select("select id as commodityId,name,intro,money,view_count,imgurl1,type from commodity")
    List<CommodityDto> getCommodityDtoList();

    @Select("select id as commodityId,name,intro,money,view_count,imgurl1 from commodity " +
            "where name like concat('%',#{nameInfo},'%')")
    List<CommodityDto> selectCommodityDtoListByName(String nameInfo);

    @Select("select id as commodityId,name,intro,money,view_count,imgurl1 from commodity " +
            "where type=#{type}")
    List<CommodityDto> selectCommodityDtoListByType(String type);
}
